$(document).ready(function() {
	
	var dates = $( "#from, #to" ).datepicker({
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
	});
	$( "#from, #to" ).datepicker($.datepicker.regional[ 'zh-CN'] );
	
	$("#searchButton").click(function(){
		$("#searchResultDiv").html("");
		$("#pageIndex").val("1");
		$("#searchResultDiv").load(getRootPath()+ "/MainMenu/profit/searchResultPage.htm",$("#memberForm").serializeArray(),function(data){
			if(data.error!=undefined){
				alert(data.error);
			}
		});
	});
});

function viewReturnHistory(memberID){
	$("#returnHistoryDiv").dialog({
		modal:true,
		width:350,
		height:400,
		autoOpen:false
	});
	
	$("#returnHistoryDiv").load(getRootPath()+ "/MainMenu/profit/returnHistory.htm",{"memberID":memberID},function(data){
		$("#returnHistoryDiv").dialog("open");
	});
}